/**
 * WTF Engine
 * 
 * License... etc.
 **
 * WTF Dev Console
 * 	(part of WTF GUI)
 * 
 * Use Ctrl+A and Ctrl+D to move the cursor, Ctrl+W and Ctrl+S to navigat through the history
 **
 * Author: Sean Micklethwaite, Mac Duy Hai
 */

#ifndef __gui_consoleH__
#define __gui_consoleH__

#include "gui_window.h"

namespace WtfGui {
	/**
	 * WTF Developer's Console
	 * 
	 * WTF Default Dev Console, executes based on wtf bindings to Python.
	 */
	class Console : public Window {
		private:
			Widgets::LogField::tRef		mLog;		///< Log Window/Field
			Widgets::InputField::tRef	mInput;		///< Input Field
			Widgets::Label::tRef		mLabel;		///< Label

		public:
			Console();
			
			/// Key Press handler
			bool OnKeyPress(int k, int flags);
			
			/// Execute Command
			void Execute(const WtfEngine::String& command);
			
			void Print(const WtfEngine::String& s) {
				mLog->Dump(s);
			};
			
			GC_AUTOSIZE(Console);
			
			void OnSelect() {
				grActiveConsole = this;
				Window::OnSelect();
			};
			void OnDeselect() {
				grActiveConsole = Console::tRef();
				Window::OnDeselect();
			};
			
		private:
			static Console::tRef		grActiveConsole;
		public:
			static const Console::tRef&	GetActiveConsole(){
				return grActiveConsole;
			};
	};
};

#endif
